
package models.spider.config;

import java.io.Serializable;

import models.spider.index.Index;
import models.spider.index.Queue;
import models.spider.policy.IPolicy;
import models.spider.policy.Policy;
import models.spider.sink.ISink;
import models.spider.sink.SinkBase;

public class Factory implements Serializable {

    public static class Empty extends Factory {

        private static final long serialVersionUID = 1L;

        private Empty() {
            super("empty");
        }

        @Override
        public IPolicy newPolicy() {
            return null;
        }

        @Override
        public Index newIndex() {
            return null;
        }

        @Override
        public Queue newQueue() {
            return null;
        }

        @Override
        public models.spider.request.Factory newRequestFactory() {
            return null;
        }

        @Override
        public ISink newSink() {
            return SinkBase.EMPTY;
        }
    }

    public static final Factory empty            = new Empty();

    private static final long   serialVersionUID = 1L;

    protected String            name             = null;

    public String getName() {
        return name;
    }

    public Factory(final String name) {
        this.name = name;
    }

    public IPolicy newPolicy() {
        return Policy.YES;
    }

    public Index newIndex() {
        return new Index();
    }

    public Queue newQueue() {
        return new Queue(newPolicy(), newIndex());
    }

    public models.spider.request.Factory newRequestFactory() {
        return new models.spider.request.Factory();
    }

    public ISink newSink() {
        return SinkBase.EMPTY;
    }

}
